import 'package:app/pages/components/moment.dart';
import 'package:app/pages/index/index_controller.dart';
import 'package:app/shared/shared.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'widget/dis_title.dart';
import 'widget/ranking.dart';

class DiscoverPage extends StatefulWidget {
  DiscoverPage({Key? key}) : super(key: key);

  @override
  _DiscoverPageState createState() => _DiscoverPageState();
}

class _DiscoverPageState extends State<DiscoverPage>
    with AutomaticKeepAliveClientMixin {
  final IndexController _controller = Get.find<IndexController>();

  @protected
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);

    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(50),
            child: AppBar(
              elevation: 0,
              backgroundColor: Colors.white,
              bottom: TabBar(
                indicatorColor: Colors.transparent,
                labelColor: Colors.black,
                labelStyle:
                    TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
                unselectedLabelStyle:
                    TextStyle(fontSize: 16, fontWeight: FontWeight.normal),
                tabs: [
                  Text(
                    "推荐",
                  ),
                  Text(
                    "关注",
                  ),
                ],
              ),
            ),
          ),
          body: TabBarView(children: <Widget>[
            SingleChildScrollView(
              child: Padding(
                  padding: EdgeInsets.all(sDefaultMarginPadding * 3),
                  child: GetBuilder(
                      builder: (IndexController controller) => MomentCom(
                            ListData: _controller.numericalList,
                          ))),
            ),
            SingleChildScrollView(
              child: Padding(
                padding: EdgeInsets.all(sDefaultMarginPadding * 3),
                child: Column(
                  children: [
                    DisTitleCom(),
                    RankIngCom(),
                    GetBuilder(
                        builder: (IndexController controller) => MomentCom(
                              ListData: _controller.numericalList,
                            )),
                  ],
                ),
              ),
            ),
          ]),
        ));
  }
}
